<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/template/common/header.jsp"%>
<script type="text/javascript">
	var popular = {
		uploadSuccess : function(file, data, response) {
			if (!response) {
				return;
			}
			var $this = $(this);
			data = eval("(" + data + ")");
			$this
					.each(function(i) {
						var $wrapper = $this[i].wrapper;
						$wrapper
								.siblings("input[name='popularCate.thumbnail']")
								.val(data.url);
						var fileQue = $wrapper.siblings("div.thumbImg");
						fileQue.empty();
						var img = $("<img src='" + resourceRootUrl + data.url
						+ "' height='150px'/>");
						fileQue.append(img);
					});
		}
	}
</script>
<div class="pageContent">
	<form method="post" action="${base }/popular_cate!doAdd.action"
		class="pageForm required-validate"
		onsubmit="return validateCallback(this, dialogAjaxDone)">
		<div class="pageFormContent" layoutH="55">
			<dl>
				<dt>分类名称：</dt>
				<dd>
					<select name="popularCate.cateId" class="combox required">
						<option value="">请选择...</option>
						<c:forEach var="category" items="${categories}">
							<option value="${category.id }">${category.title }</option>
						</c:forEach>
					</select>
				</dd>
			</dl>
			<dl>
				<dt>序号：</dt>
				<dd>
					<input type="text" name="popularCate.orders"
						class="required digits" />
				</dd>
			</dl>
			<dl>
				<dt>图片：</dt>
				<dd>
					<input id="${rel }FilePopularAdd" target="uploadify" type="file"
						name="filedata"
						uploadifyOpts='{"onUploadSuccess":popular.uploadSuccess}' /> <input
						type="hidden" name="popularCate.thumbnail" class="required">
					<div class="thumbImg"></div>
				</dd>
			</dl>
		</div>
		<div class="formBar">
			<ul>
				<li><div class="buttonActive">
						<div class="buttonContent">
							<button type="submit">提交</button>
						</div>
					</div></li>
				<li><div class="button">
						<div class="buttonContent">
							<button type="button" class="close">取消</button>
						</div>
					</div></li>
			</ul>
		</div>
	</form>
</div>
